/*
-------------------------------------------------------------------
BIE is Copyright 2001-2003 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
*/
package com.webdeninteractive.sbie;

import java.io.InputStream;
import java.io.OutputStream;
import org.w3c.dom.Document;

import com.webdeninteractive.sbie.Client;
import com.webdeninteractive.sbie.ServiceEndpoint;
import com.webdeninteractive.sbie.exception.TransportException;

/**
 * Interface for sending SBIE messages via a particular protocol or transport.
 *
 * @author gfast
 * @version $Id: ProtocolHandler.java,v 1.1.1.1 2003/05/20 16:56:49 gdf Exp $ 
 */
public interface ProtocolHandler {

    /** Tell this this ProtocolHandler about the Client which created it.
     * @param parent The Client which created this ProtocolHandler.
     */
    public void setParentClient( Client parent );

    /** Return the Client implementation which created this ProtocolHandler */
    public Client getParentClient();

    /** Send a message via the implemented protocol.
     *  It's up to a Service calling this method to package and interpret 
     *  the message .
     *  @param message Document containing data to send as message.
     *  @return Document containing response message.
     *  @throws TransportException if the message cannot be sent.
     */
    public Document sendMessage(ServiceEndpoint endpoint, Document message)
        throws TransportException;

    /** Create a new ServiceEndpoint appropriate for this ProtocolHandler.
     *  This ProtocolHandler will use the given Service to configure the
     *  ServiceEndpoint returned.
     * @return an endpoint object representing the service's endpoint.
     */
    public ServiceEndpoint createServiceEndpoint( Service service );

    //public OutputStream sendMessage(ServiceEndpoint endpoint, InputStream in);

}

